// Copyright 2008 David Mitchell
// Released under the MIT License

using NSDuctTape;

namespace CurrencyConverter
{
	public class Converter : NotifyPropertyChangingBase
	{
		public Converter()
		{
		}

		public float SourceCurrencyAmount
		{
			get { return _sourceCurrencyAmount; }
			set
			{
				using (ChangeProperties("SourceCurrencyAmount"))
					_sourceCurrencyAmount = value;
			}
		}
		
		public float Rate
		{
			get { return _rate; }
			set
			{
				using (ChangeProperties("Rate"))
					_rate = value;
			}
		}
		
		public float ConvertedAmount
		{
			get { return _convertedAmount; }
			private set
			{
				using (ChangeProperties("ConvertedAmount"))
					_convertedAmount = value;
			}
		}
		
		public void UpdateConvertedAmount()
		{
			ConvertedAmount = SourceCurrencyAmount * Rate;
		}
		
		float _sourceCurrencyAmount;
		float _rate;
		float _convertedAmount;
	}
}
